package com.ironman.imes.device.event.listener;

import lombok.extern.slf4j.Slf4j;
import org.noear.dami.DamiConfig;
import org.noear.dami.bus.impl.RoutingPath;
import org.noear.dami.bus.impl.TopicRouterPatterned;
import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.core.env.ConfigurableEnvironment;


/**
 * description
 * company 铁人科技
 *
 * @author 陈浩杰
 * @date 2025/1/6 22:17
 */
@Slf4j
public class DeviceEventAppRunListener implements SpringApplicationRunListener {

    final SpringApplication application;

    final String[] args;

    public DeviceEventAppRunListener(SpringApplication application, String[] args) {
        this.application = application;
        this.args = args;
    }

    @Override
    public void environmentPrepared(ConfigurableBootstrapContext bootstrapContext, ConfigurableEnvironment environment) {
        log.info("DeviceEventAppRunListener.environmentPrepared");
        DamiConfig.configure(new TopicRouterPatterned<>(RoutingPath::new));
    }
}